const { Model } = require('sequelize');

module.exports = (sequelize, DataTypes) => {
  class Chapter extends Model {
    static associate(models) {
      // 定义关联关系
      Chapter.belongsTo(models.Novel, { foreignKey: 'novel_id' });
    }
  }
  Chapter.init({
    title: DataTypes.STRING,
    content: DataTypes.TEXT,
    novel_id: DataTypes.INTEGER
  }, {
    sequelize,
    modelName: 'Chapter',
  });
  return Chapter;
};